<template>
	<el-container>
		<el-main class='x-main-edit'>
			<el-form ref="form" :rules="form_rules" :model="form" size="mini" label-width="15%">
				<el-tabs type="border-card" v-model="page_tag">
					<!---->
					<!---->
					<el-tab-pane :label="page_info.title" name="1">
						<el-form-item label="相关链接">
							<div class="x-alert">
								<span>抽奖活动：/pages/app_lacsoce_v2/draw/draw?aset_id=活动ID</span><br/>
								<span>产品详情页：/pages/app_lacsoce_v2/goods_detail/goods_detail?id=产品ID</span><br/>
							</div>
						</el-form-item>
						<el-form-item label="首页活动列表">
							<ItemList ref="item_list_00"></ItemList>
							<div class="x-alert">
								<span>提示：可以用鼠标拖拽改变排序</span>
							</div>
						</el-form-item>
						<el-form-item label="规则说明">
							<Tinymce menubar="" v-model="form.rule" :height="350" ref="rule"></Tinymce>
						</el-form-item>
						<el-form-item label="顶部图片">
							<x-upload-imgs ref="uploadEle" :sortable="true" :max-num="1"
										   :img_root="page_info.static_file_root"
										   v-bind:value.sync="form.top_pic"
										   :remote-fuc="g_page.funcUpdateImg"
										   :before-upload="g_page.funcUpdateImgBefore"/>
						</el-form-item>
						<el-form-item label="市场部图片">
							<x-upload-imgs ref="uploadEle" :sortable="true" :max-num="1"
										   :img_root="page_info.static_file_root"
										   v-bind:value.sync="form.market_pic"
										   :remote-fuc="g_page.funcUpdateImg"
										   :before-upload="g_page.funcUpdateImgBefore"/>
						</el-form-item>
						<el-form-item label="隐私政策">
							<x-upload-imgs ref="uploadEle" :sortable="true" :max-num="1"
										   :rules="({ maxSize: 2})"
										   :img_root="page_info.static_file_root"
										   v-bind:value.sync="form.privacy_pic"
										   :remote-fuc="g_page.funcUpdateImg"
										   :before-upload="g_page.funcUpdateImgBefore"/>
						</el-form-item>
						<el-form-item label="使用条款">
							<x-upload-imgs ref="uploadEle" :sortable="true" :max-num="1"
										   :rules="({ maxSize: 2})"
										   :img_root="page_info.static_file_root"
										   v-bind:value.sync="form.terms_pic"
										   :remote-fuc="g_page.funcUpdateImg"
										   :before-upload="g_page.funcUpdateImgBefore"/>
						</el-form-item>
						<el-form-item label="厘肤星球协议">
							<x-upload-imgs ref="uploadEle" :sortable="true" :max-num="1"
										   :rules="({ maxSize: 2})"
										   :img_root="page_info.static_file_root"
										   v-bind:value.sync="form.agreement_pic"
										   :remote-fuc="g_page.funcUpdateImg"
										   :before-upload="g_page.funcUpdateImgBefore"/>
						</el-form-item>
					</el-tab-pane>
					<!---->
					<!---->
					<el-tab-pane label="我的" name="2">
						<el-form-item label="平台权益">
							<x-upload-imgs ref="uploadEle" :sortable="true" :max-num="1"
										   :rules="({ maxSize: 2})"
										   :img_root="page_info.static_file_root"
										   v-bind:value.sync="form.platform_pic"
										   :remote-fuc="g_page.funcUpdateImg"
										   :before-upload="g_page.funcUpdateImgBefore"/>
						</el-form-item>
						<el-form-item label="值供品说明">
							<x-upload-imgs ref="uploadEle" :sortable="true" :max-num="1"
										   :rules="({ maxSize: 2})"
										   :img_root="page_info.static_file_root"
										   v-bind:value.sync="form.goods_pic"
										   :remote-fuc="g_page.funcUpdateImg"
										   :before-upload="g_page.funcUpdateImgBefore"/>
						</el-form-item>
					</el-tab-pane>
					<el-tab-pane label="厘肤商城" name="3">
						<el-form-item label="轮播图列表">
							<ItemList ref="item_list_01"></ItemList>
							<div class="x-alert">
								<span>提示：可以用鼠标拖拽改变排序</span>
							</div>
						</el-form-item>
						<el-form-item label="下单成功页-拼团">
							<x-upload-imgs ref="uploadEle" :sortable="true" :max-num="1"
										   :rules="({ maxSize: 0.5})"
										   :img_root="page_info.static_file_root"
										   v-bind:value.sync="form.order_success_act"
										   :remote-fuc="g_page.funcUpdateImg"
										   :before-upload="g_page.funcUpdateImgBefore"/>
						</el-form-item>
						<el-form-item label="下单成功页-大转盘">
							<x-upload-imgs ref="uploadEle" :sortable="true" :max-num="1"
										   :rules="({ maxSize: 0.5})"
										   :img_root="page_info.static_file_root"
										   v-bind:value.sync="form.order_success_chou"
										   :remote-fuc="g_page.funcUpdateImg"
										   :before-upload="g_page.funcUpdateImgBefore"/>
						</el-form-item>
					</el-tab-pane>
					<el-tab-pane label="顾问星球" name="4">
						<el-form-item label="赠送运费" prop="give_fun" ref="give_fun">
							<el-input-number v-model="form.give_fun" :step="1"></el-input-number>
							{{ page_info.fun_name }}
						</el-form-item>
					</el-tab-pane>
					<!---->
					<!---->
					<el-tab-pane v-if="false" label="模板" name="2">
						<el-form-item label="应用模板" prop="reply_app_file" ref="reply_app_file">
							<el-col :span="6">
								<el-input v-model="form.reply_app_file" placeholder="默认：t_001"/>
							</el-col>
						</el-form-item>
					</el-tab-pane>
					<!---->
					<!---->
				</el-tabs>
				<!---->
				<!---->
			</el-form>
			<!---->
			<!---->
			<!-- 按钮部分 -->
			<div class="save_wrap">
				<!--				<el-button @click="funcTest" size="mini">test</el-button>-->
				<!--				<el-button @click="g_page.funcBack" size="mini">返回</el-button>-->
				<el-button type="success" @click="g_page.funcSave" size="mini">保存</el-button>
				<el-checkbox v-if="page_info.is_admin_edit" style="margin-left: 10px;" label="保存后停留" v-model="checked"/>
			</div>
			<!---->
			<!---->
			<!---->
		</el-main>
	</el-container>
</template>

<script>
	import ItemList from '@/components/CompItem/ItemList'
	import Tinymce from '@/components/Tinymce'

	export default {
		components: {
			ItemList,
			Tinymce
		},
		data() {
			let page_data = { pid: '' }
			//
			page_data = this.g_cc.funcGetInitData(page_data)
			//
			return page_data
		},
		mounted() {
			console.log('mounted', this._uid)
			console.log(this.$route.query)

			this.g_page.funcSetVue(this)
			//
			this.g_page.funcSetApiUrlEdit('/xadmin/app_lacsoce/app_lacsoce_mall__setting')
			this.g_page.funcSetApiUrlSave('/xadmin/app_lacsoce/app_lacsoce_mall__setting/save')
			let page = this
			//验证
			this.form_rules = {
				__test: [{
					required: true,
					message: '请输入原密码',
					trigger: 'blur'
				}]
			}

			let data = this.$route.query
			this.g_page.funcEdit(data)
		},
		methods: {
			funcTest() {
				console.log(this.$route.fullPath)
				// let url = `/302?callback_url=${encodeURIComponent(this.$route.fullPath)}`
				this.g_cc.func_redirect(this.$route.fullPath)
			},
			funcShowDialogAfter() {
				this.$nextTick(() => {
					this.$refs['item_list_00'].funcInit(this.form.abc_str_00)
					this.$refs['item_list_01'].funcInit(this.form.abc_str_01)
					// debugger
					setTimeout(() => {
						this.$refs['rule'].setContent(this.form.rule)
					}, 200)
				})
			},
			//保存之前
			funcSaveBefore(data) {
				console.log('funcSaveBefore', data)

				// data.sheet_banner_imgs = this.g_page.funcImgArrToStr(data.sheet_banner_imgs)

				return data
			}
			////////////////
		}
	}
</script>
